package vip.liux.backend.adapter.controllers;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.backend.application.service.shop.RegionDto;
import vip.liux.backend.application.service.shop.RegionService;

import java.util.Map;

@RestController
@RequestMapping("/api/region")
public class RegionController {

    private final RegionService regionService;

    public RegionController(RegionService regionService) {
        this.regionService = regionService;
    }

    @GetMapping("/all")
    public Map<Long, RegionDto> all() {
        return regionService.getCacheAll();
    }

    @GetMapping("/tree")
    public Map<Long, RegionDto> tree() {
        return regionService.getCacheTree();
    }
}

